<?php 
// +----------------------------------------------------------------------
// | RXThinkCMF_EVTP5.1_PRO前后端分离旗舰版框架 [ RXThinkCMF ]
// +----------------------------------------------------------------------
// | 版权所有 2018~2021 南京RXThinkCMF研发中心
// +----------------------------------------------------------------------
// | 官方网站: http://www.rxthink.cn
// +----------------------------------------------------------------------
// | 作者: ZhangXuanNeng <rxthinkcmf@163.com>
// +----------------------------------------------------------------------
// | 免责声明:
// | 本软件框架禁止任何单位和个人用于任何违法、侵害他人合法利益等恶意的行为，禁止用于任何违
// | 反我国法律法规的一切平台研发，任何单位和个人使用本软件框架用于产品研发而产生的任何意外
// | 、疏忽、合约毁坏、诽谤、版权或知识产权侵犯及其造成的损失 (包括但不限于直接、间接、附带
// | 或衍生的损失等)，本团队不承担任何法律责任。本软件框架只能用于公司和个人内部的法律所允
// | 许的合法合规的软件产品研发，详细声明内容请阅读《框架免责声明》附件；
// +----------------------------------------------------------------------

namespace app\admin\service;


use app\admin\model\BoxMediaOrderLog;
use app\common\controller\PaySuccess;

/**
 * 订单列管理-服务类
 * @author ZhangXuanNeng
 * @since: 2023/07/25
 * Class OrderService
 * @package app\admin\service
 */
class BoxNotMediaOrderService extends BaseService
{
    /**
     * 构造函数
     * LevelService constructor.
     */
    public function __construct()
    {
        $this->model = new BoxMediaOrderLog();
    }

    /**
     * Desc :
     * User : you name
     * Date : 2024-05-09 18:36
     * @return array
     */
    public function getList(): array
    {
        $param = request()->param();

        // 查询条件
        $map = [];
		

        $pay_status = isset($param['pay_status']) ? (int)$param['pay_status'] : 0;
        if ($pay_status) {
            $map[] = ['pay_status', '=', $pay_status];
        }
        if(isset($param['member_id']) && !empty($param['member_id'])){
            $map[] = ['member_id','=',$param['member_id']];
        }
        if(isset($param['member_account']) && !empty($param['member_account'])){
            $map[] = ['member_account','=',$param['member_account']];
        }
        if(isset($param['package_id']) && !empty($param['package_id'])){
            $map[] = ['package_id','=',$param['package_id']];
        }
        if(isset($param['promote_id']) && !empty($param['promote_id'])){
            $map[] = ['promote_id','=',$param['promote_id']];
        }
        if(isset($param['game_role_id']) && !empty($param['game_role_id'])){
            $map[] = ['game_role_id','=',$param['game_role_id']];
        }
        if(isset($param['game_role_name']) && !empty($param['game_role_name'])){
            $map[] = ['game_role_name','like','%'.$param['game_role_name'].'%'];
        }
        if(isset($param['pay_way']) && !empty($param['pay_way'])){
            $map[] = ['pay_way','=',$param['pay_way']];
        }
        if(isset($param['pay_game_status']) && !empty($param['pay_game_status'])){
            $map[] = ['pay_game_status','=',$param['pay_game_status']];
        }
        if(isset($param['pay_time']) && !empty($param['pay_time'])){
            $map[] = ['pay_time','between time',$param['pay_time']];
        }
        if(isset($param['pay_order_number']) && !empty($param['pay_order_number'])){
            $map[] = ['pay_order_number','=',$param['pay_order_number']];
        }

        $data = $this->model->where($map)->order('id', 'desc')->page(PAGE, PERPAGE)->select();
        //获取数据总数
        $count = $this->model->where($map)->count();

        //返回结果
        return [
            "msg"   => '操作成功',
            "code"  => 0,
            "data"  => $data,
            "count" => $count,
        ];

//        return parent::getListNewNoCache($map); // TODO: Change the autogenerated stub
    }

    public function gamePayNotify(){
        $param = request()->param();
        $rows = $this->model->where('id','in',$param['ids'])->select();
        $paySuccess = new PaySuccess();
        $res = '';
        foreach ($rows as $k=>$v){
            $res .= $paySuccess->gamePayNotify($v);
        }
        $message = array(
            "msg" => '操作成功',
            "code" => 0,
            "data" => $res,
        );
        return $message;
    }
    /**
     * 生成导出队列
     * @return array
     * @since 2024/01/30
     * @author ZhangXuanNeng
     */
    public function exportQueue(){
        $param = request()->param();
        $row = $this->model->exportQueue($param);
        return $row;
    }
                                                                                                                                            
}